#pragma once

#include "Type.h"
#include "Vector2.h"
#include "Vector3.h"

namespace Common
{
	class Line2D
	{
	public:
		/// simple constructor
		Line2D( const Vector2 & normal, const float d )
			:m_vNormal( normal ), m_fDistance( d ) {}

		Line2D( const Vector2& v0, const Vector2& v1 );
		/**
		*	This method intersects this line with the other, returning the
		*	distance along the line that the intersection occurs.
		*/
		float intersect( const Line2D & other ) const;
		/**
		*	Return the point that corresponds tot he given parameter
		*/
		Vector2 param( float t ) const;
		/**
		*	Return the parameter of the given point projected onto the line
		*/
		float project( const Vector2& point ) const;
		/**
		*	Returns whether or not the given line is a minimum cutter of our line.
		*
		*	A minimum cutter means that if the intersection is greater than the
		*	minimum, this intersection forms the new minimum.
		*/
		bool isMinCutter( const Line2D& cutter ) const;
		/**
		*	Returns whether or not this line is parallel with the other
		*/
		bool isParallel( const Line2D& other ) const;
		/**
		*	Returns whether or not the given point is in front of the line
		*/
		bool isInFrontOf( const Vector2& point ) const;

		const Vector2& normal() const	{ return m_vNormal; }
		float d() const					{ return m_fDistance; }

	private:
		Vector2		m_vNormal;
		float		m_fDistance;
	};

	class Line3D
	{
	public:
		Line3D( const Vector3& point1, const Vector3& point2 );
		~Line3D(void);

		float DistanceToPoint( const Common::Vector3& point ) const;
		bool IsValid( void ) const;
	private:

		Vector3		m_vOriPoint;
		Vector3		m_vDirection;
	};

}